<template>
  <view>
    <!--    配件卡片 -->
    <view
      v-if="info.type === 'accessory' || info.type === 'accessoryOrder'"
      class="accessory-box"
      :class="isMsg ? 'wrapper' : 'wrapper-msg'"
    >
      <view class="item">
        <view class="left-accessory" v-if="info.imgSrc">
          <image
            :src="info.imgSrc"
            mode="scaleToFill"
            :class="isMsg ? 'img' : 'img-msg'"
          ></image>
        </view>
        <view class="left-accessory"> 车型：</view>
        <view class="right flex">
          <view class="name">{{ info.name }}</view>
        </view>
      </view>
      <view class="item pt-25">
        <view class="left-accessory"> 需求配件： </view>
        <view class="right felx">
          <view class="name-detail">
            {{ info.carPartDetailsStr }}
          </view>
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
    <!--    寻车-->
    <view
      v-else-if="info.type === 'findCar'"
      class="box findcar-box"
      :class="isMsg ? 'wrapper' : 'wrapper-msg'"
    >
      <view class="left-img" v-if="info.imgSrc">
        <image :src="info.imgSrc" mode="scaleToFill" class="img"></image>
      </view>
      <view class="right">
        <view class="name">{{ info.name }}</view>
        <view class="info">
          <view class="price-box"
            >报价:<text class="price">￥{{ info.price }}</text></view
          >
          <view class="label-price" v-if="isMsg && info.imgSrc"
            >指导价:{{ info.labelPrice }}</view
          >
        </view>
        <view class="btn-wrap">
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
    <!--    车品-->
    <view
      v-else-if="info.type === 'carGoods'"
      class="box"
      :class="isMsg ? 'wrapper' : 'wrapper-msg'"
    >
      <view class="left-img" v-if="info.imgSrc">
        <image :src="info.imgSrc" mode="scaleToFill" class="img"></image>
      </view>
      <view class="right">
        <view class="name">{{ info.name }}</view>
        <view class="info">
          <view class="price" :class="isMsg ? '' : 'font-26'"
            >￥{{ info.price }}</view
          >
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
    <!--   寻车零售订单-->
    <view
      v-else-if="info.type === 'resaleCar'"
      class="box"
      :class="isMsg ? 'wrapper' : 'wrapper-msg'"
    >
      <view class="left-img" v-if="info.imgSrc">
        <image :src="info.imgSrc" mode="scaleToFill" class="img"></image>
      </view>
      <view class="right">
        <view class="name">{{ info.name }}</view>
        <view class="info">
          <view class="price"
            ><text v-if="info.price"> ￥{{ info.price }}</text></view
          >
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
    <!-- 维保订单 -->
    <view
      v-else-if="info.type === 'afterSales'"
      class="box"
      :class="isMsg ? 'wrapper' : 'wrapper-msg'"
    >
      <view class="left-img afterSales-img" v-if="info.imgSrc">
        <image :src="info.imgSrc" mode="scaleToFill" class="img"></image>
      </view>
      <view class="right">
        <view class="name font-bold">{{ info.name }}</view>
        <view class="font-20 color-999">{{ info.subName }}</view>
        <view class="info">
          <view class="color-999 font-20">
            小计:<text class="afterSales-price pr-10">￥{{ info.price }}</text
            ><text v-if="isMsg"
              >已优惠<text>￥{{ info.discounts }}</text></text
            ></view
          >
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
    <!--    车型和订单-->
    <view v-else class="box" :class="isMsg ? 'wrapper' : 'wrapper-msg'">
      <!-- 车型页面进入显示车标 订单页面进入显示车辆主图 -->
      <view class="left-img" v-if="info.imgSrc != '' && info.imgSrc != 'null'">
        <image
          :src="info.imgSrc"
          mode="scaleToFill"
          :class="info.labelPrice ? 'img' : 'carImg1'"
        ></image>
      </view>

      <view class="right">
        <view class="name">{{ info.name }}</view>
        <view class="info">
          <view class="price" :class="isMsg ? '' : 'font-26'"
            >￥{{ info.price }}
            <text class="label-price" v-if="isMsg && info.labelPrice"
              >指导价:{{ info.labelPrice }}</text
            >
          </view>
          <view class="btn" v-if="isMsg" @click="sendCardMsg">发送</view>
        </view>
      </view>
      <view class="close" @click="close" v-if="isMsg">
        <u-icon name="close" color="#9A9A9A" size="32rpx"></u-icon>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {}
  },
  props: {
    isMsg: {
      //是否显示为卡片
      type: Boolean,
      default: false,
    },
    info: {
      type: Object,
      default() {
        return {
          imgSrc: '',
          name: '',
          price: '0.00',
          labelPrice: '0.00',
          type: 'orderInfo',
        }
      },
    },
  },
  methods: {
    sendCardMsg() {
      this.$emit('sendCard')
    },

    close() {
      this.$emit('close')
    },
  },
}
</script>

<style lang="scss" scoped>
.wrapper {
  width: 700rpx;
  padding: 16rpx;
  border-radius: 10rpx;

  .left-img {
    width: 146rpx;
    height: 120rpx;
    padding-right: 10rpx;

    .img {
      width: 120rpx;
      height: 120rpx;
    }

    .carImg1 {
      width: 140rpx !important;
      height: 104rpx !important;
      margin-right: 10rpx;
      border-radius: 10rpx !important;
    }
  }

  .right {
    .name {
      padding-right: 90rpx;
    }
  }
}

.wrapper-msg {
  width: 350rpx;

  .left-img {
    width: 83rpx;
    height: 73rpx;
    padding-right: 10rpx;

    .img {
      width: 73rpx;
      height: 73rpx;
    }
    .carImg1 {
      width: 73rpx !important;
      height: 73rpx !important;
      margin-right: 10rpx;
      border-radius: 10rpx !important;
    }
  }

  .afterSales-img {
    width: 130rpx;
    height: 120rpx;
    padding-right: 10rpx;

    .img {
      width: 120rpx;
      height: 120rpx;
    }
  }
  .right {
    .name,
    .name-detail {
      font-size: 24rpx !important;
    }
    .info {
      .price-box {
        .price {
          font-size: 26rpx;
        }
      }
      .price {
        font-size: 26rpx;
      }
    }
  }
}

.box {
  display: flex;
  flex-direction: row;
  background-color: #fff;
  position: relative;

  .right {
    flex: 1;
    font-size: 28rpx;
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;

    .name {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden;
    }

    .font-20 {
      font-size: 20rpx;
    }

    .info {
      display: flex;
      flex-direction: row;
      align-items: center;
      justify-content: space-between;
      padding-top: 5rpx;

      .price {
        font-size: 34rpx;
        color: #eb5c02;
        font-weight: bold;
      }

      .afterSales-price {
        font-size: 28rpx;
        color: #eb5c02;
        font-weight: bold;
      }
      .pr-10 {
        padding-right: 10rpx;
      }

      .font-26 {
        font-size: 26rpx;
      }

      .label-price {
        font-size: 24rpx;
        color: #999;
        font-weight: 500;
        padding-left: 20rpx;
        flex: 1;
      }

      .info-item {
        font-size: 24rpx;
        color: #333;
        font-weight: 500;
        flex: 1;
      }

      .btn {
        width: 140rpx;
        height: 56rpx;
        line-height: 56rpx;
        text-align: center;
        border-radius: 28rpx;
        background: linear-gradient(-90deg, #fdd421, #ffe23e);
        color: #333;
        font-weight: 28rpx;
        font-weight: 500;
      }

      .btn:hover {
        opacity: 0.7;
      }
    }
  }
}

.accessory-box {
  background-color: #fff;
  position: relative;

  .pt-25 {
    padding-top: 25rpx;
  }

  .item {
    display: flex;

    .left-accessory {
      color: #999;
      font-size: 26rpx;

      .img {
        width: 56rpx;
        height: 56rpx;
      }

      .img-msg {
        width: 24rpx;
        height: 24rpx;
      }
    }

    .right {
      flex: 1;
      display: flex;
      overflow: hidden;

      .name {
        font-size: 28rpx;
        color: #333;
        display: -webkit-box;
        overflow: hidden;
        text-overflow: ellipsis;
        word-wrap: break-word;
        white-space: normal !important;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }

      .name-detail {
        flex: 1;
        font-size: 28rpx;
        color: #333;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
      }

      .btn {
        width: 140rpx;
        height: 56rpx;
        line-height: 56rpx;
        text-align: center;
        border-radius: 28rpx;
        background: linear-gradient(-90deg, #fdd421, #ffe23e);
        color: #333;
        font-weight: 28rpx;
        font-weight: 500;
      }
    }
  }
}

.findcar-box {
  .info {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .price-box {
    font-size: 24rpx;
    color: #999;
  }

  .btn-wrap {
    display: flex;
    flex-direction: row-reverse;
    padding-top: 10rpx;
  }

  .btn {
    width: 140rpx;
    height: 56rpx;
    line-height: 56rpx;
    text-align: center;
    border-radius: 28rpx;
    background: linear-gradient(-90deg, #fdd421, #ffe23e);
    color: #333;
    font-weight: 28rpx;
    font-weight: 500;
  }
}

.close {
  position: absolute;
  right: 10rpx;
  top: 15rpx;
}
</style>
